<?php /*a:3:{s:73:"E:\phpstudy_pro\WWW\YZNCMS-master\application\admin\view\product\add.html";i:1629871806;s:74:"E:\phpstudy_pro\WWW\YZNCMS-master\application\admin\view\index_layout.html";i:1629258949;s:67:"E:\phpstudy_pro\WWW\YZNCMS-master\application\admin\view\layui.html";i:1629258949;}*/ ?>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>YZNCMS后台管理系统</title>
    <meta name="author" content="YZNCMS">
    <meta name="csrf-token" content="<?php echo think\facade\Request::token('__token__'); ?>">
    <link rel="stylesheet" href="/static/libs/layui/css/layui.css">
    <link rel="stylesheet" href="/static/admin/css/admin.css?v=<?php echo htmlentities(app('config')->get('version.yzncms_release')); ?>">
    <link rel="stylesheet" href="/static/common/font/iconfont.css?v=<?php echo htmlentities(app('config')->get('version.yzncms_release')); ?>">
    <script src="/static/libs/layui/layui.js"></script>
    <script src="/static/libs/jquery/jquery.min.js"></script>
    <script type="text/javascript">
    //全局变量
    var GV = {
        'site':<?php echo json_encode($site); ?>,
        'image_upload_url': '<?php echo !empty($image_upload_url) ? htmlentities($image_upload_url) :  url("attachment/upload/upload", ["dir" => "images", "module" => request()->module()]); ?>',
        'file_upload_url': '<?php echo !empty($file_upload_url) ? htmlentities($file_upload_url) :  url("attachment/upload/upload", ["dir" => "files", "module" => request()->module()]); ?>',
        'ueditor_upload_url': '<?php echo !empty($ueditor_upload_url) ? htmlentities($ueditor_upload_url) :  url("attachment/upload/upload", ["dir" => "images","from"=>"ueditor", "module" => request()->module()]); ?>',
    };
    </script>
</head>

<body class="childrenBody <?php echo defined('IS_DIALOG') && IS_DIALOG ? 'is-dialog' : ''; ?>">
    
<form class="layui-form" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="bitian">*</span>产品编号 </label>
        <div class="layui-input-block">
            <input type="text" name="nums" lay-verify="required" autocomplete="off" placeholder="产品编号" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="bitian">*</span>产品名称 </label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="required" autocomplete="off" placeholder="产品名称" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="bitian">*</span>库存单位 </label>
        <div class="layui-input-block">
            <select name="danwei_id">
                <?php if(is_array($danwei) || $danwei instanceof \think\Collection || $danwei instanceof \think\Paginator): $i = 0; $__LIST__ = $danwei;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$item): $mod = ($i % 2 );++$i;?>
                <option value="<?php echo htmlentities($item['id']); ?>"><?php echo htmlentities($item['title']); ?></option>
                <?php endforeach; endif; else: echo "" ;endif; ?>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">产品规格 </label>
        <div class="layui-input-block">
            <input type="text" name="guige" autocomplete="off" placeholder="产品规格" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">库存数量 </label>
        <div class="layui-input-block">
            0
        </div>
    </div>
    <?php if(is_array($custom) || $custom instanceof \think\Collection || $custom instanceof \think\Paginator): $k = 0; $__LIST__ = $custom;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$item): $mod = ($k % 2 );++$k;switch($item['field_type']): case "text": ?>
                <div class="layui-form-item">
                    <label class="layui-form-label"><?php if(strpos($item['attribute']['attribute'],'2') !== false): ?> <span class="bitian">*</span><?php endif; ?> <?php echo htmlentities($item['title']); ?> </label>
                    <div class="layui-input-block">
                        <input type="hidden" name="extra-title[]" value="<?php echo htmlentities($item['title']); ?>">
                        <input type="hidden" name="field_type[]" value="<?php echo htmlentities($item['field_type']); ?>">
                        <input type="text" name="extra[]" <?php if(strpos($item['attribute']['attribute'],'2') !== false): ?> lay-verify="required" <?php endif; ?> autocomplete="off" placeholder="<?php echo htmlentities($item['attribute']['placeholder']); ?>" class="layui-input <?php if(strpos($item['attribute']['attribute'],'1') !== false): ?> layui-disabled <?php endif; ?>">
                    </div>
                </div>
            <?php break; case "number": ?>
                <div class="layui-form-item">
                    <label class="layui-form-label"><?php if(strpos($item['attribute']['attribute'],'2') !== false): ?> <span class="bitian">*</span><?php endif; ?> <?php echo htmlentities($item['title']); ?> </label>
                    <div class="layui-input-block">
                        <input type="hidden" name="extra-title[]" value="<?php echo htmlentities($item['title']); ?>">
                        <input type="hidden" name="field_type[]" value="<?php echo htmlentities($item['field_type']); ?>">
                        <input type="text" name="extra[]" <?php if(strpos($item['attribute']['attribute'],'2') !== false): ?> lay-verify="required" <?php endif; ?> autocomplete="off" placeholder="<?php echo htmlentities($item['attribute']['placeholder']); ?>" class="layui-input <?php if(strpos($item['attribute']['attribute'],'1') !== false): ?> layui-disabled <?php endif; ?>" <?php if(strpos($item['attribute']['attribute'],'4') !== false): ?> onclick="saveXiaoshu(this,'<?php echo htmlentities($item['attribute']['xiaoshu']); ?>')"<?php endif; if(strpos($item['attribute']['attribute'],'3') !== false): ?> qian="1" onkeyup="SnumFormat(this)" <?php endif; ?> >
                    </div>
                </div>
            <?php break; ?>

        <?php endswitch; ?>
    <?php endforeach; endif; else: echo "" ;endif; ?>

    <div class="layui-form-item layer-footer">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter='ds' type="button" data-refresh="false">立即提交</button>
            <button class="layui-btn layui-btn-normal" type="button" onclick="var index1 = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index1);">返回</button>
        </div>
    </div>
</form>

    
    <script type="text/javascript">
layui.config({
	version: '<?php echo htmlentities(app('config')->get('version.yzncms_release')); ?>',
	base: '/static/libs/layui_exts/'
}).extend({
	yzn: 'yzn/yzn',
	yznForm: 'yznForm/yznForm',
	yznTable: 'yznTable/yznTable',
	treeGrid: 'treeGrid/treeGrid',
	clipboard: 'clipboard/clipboard',
	notice: 'notice/notice.min',
	iconPicker: 'iconPicker/iconPicker.min',
	ztree: 'ztree/ztree',
	dragsort: 'dragsort/dragsort.min',
	tagsinput: 'tagsinput/tagsinput',
	xmSelect: 'xmSelect/xm-select',
	selectPage: 'selectPage/selectpage.min',
	echarts: 'echarts/echarts',
	echartsTheme: 'echarts/echartsTheme',
	citypicker: 'citypicker/city-picker',
	webuploader: 'webuploader/webuploader',
	ueditor: 'ueditor/ueditor.min',
}).use('yznForm');
</script>
    
    
<script>
    layui.use(['form','jquery'], function() {
        var form = layui.form;
        var $ = layui.jquery;
        form.on('submit(ds)',function(data){
            var param = data.field;
            $.post('<?php echo url("editPost"); ?>',param,function(res){
                if(res.code > 0){
                    layer.msg('添加成功');
                    setTimeout(() => {
                        var index1 = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index1);
                        parent.location.reload();
                    }, 500);
                }else{
                    layer.msg(res.msg);
                }
            },'json');
        })
        
    })
    
    function saveXiaoshu(e,xiaoshu){
        $(e).on("input", function(){
            var v = $(this).val()
            v = v.replace(/,/g,'');
            v = parseFloat(v);
            xiaoshu = parseInt(xiaoshu);
            var qian = $(e).attr('qian');
            if(isNaN(v) || Number(v) == 0 || v == ''){
                $(this).val("0"); // 解析出错，默认0
            } else {
                setTimeout(() => {
                    var numb = Number(v).toFixed(xiaoshu);
                    if(qian){
                        numb = numFormat(numb);
                    }
                    $(this).val(numb);
                }, 2000);
            }
        });
    }
    function SnumFormat(e){
        var num = $(e).val();
        num = num.replace(/,/g,'');
        console.log(num);
        var nums = numFormat(num);
        $(e).val(nums);
    }
    function numFormat(num){
        console.log(num);
        num=num.toString().split(".");  // 分隔小数点
        var arr=num[0].split("").reverse();  // 转换成字符数组并且倒序排列
        var res=[];
        for(var i=0,len=arr.length;i<len;i++){
            if(i%3===0&&i!==0){
                res.push(",");   // 添加分隔符
            }
            res.push(arr[i]);
        }
        res.reverse(); // 再次倒序成为正确的顺序
        if(num[1]){  // 如果有小数的话添加小数部分
            res=res.join("").concat("."+num[1]);
        }else{
            res=res.join("");
        }
        return res;
    }
</script>

</body>

</html>